#!usr/bin/node

const {EventEmitter} = require('events');

class Dog extends EventEmitter{
  constructor(name,energy) {
    super();

    this.#name = name;
    this.#energy = energy;

    const timer = setInterval(()=>{
      if(this.#energy < 0) {
        clearInterval(timer);
        return ;
      }else{
        this.emit("bark",this.#name,this.#energy--);
      }
    },1000)
  }

  #name = '';
  #energy = 0;
}

module.exports = Dog;
